Using WS-AppServer Custom Class as an Alternative to Object Template |
|
Object Template has been deprecated in BOP 4.1. Hence, you cannot create a new Object Template from document creation wizard. However, if there are object templates used in the applications build prior to BOP 4.1, you can create and use WS-AppServer Custom Classes replicating the object template schema.
Similar to an Object Template, you can do the following with WS-AppServer custom class:
- Generate schema and schema fragments
- Provide unique fields (analogous to the Special Attribute feature of Object Template)
- Generate Web services, use these Web services to fetch the instances matching the search criteria.
- Model rule(s), decision table(s), and data transformation(s)
This page illustrates the procedure and guidelines that are used to create a custom class and remodel the object template schema to WS-AppServer custom class.
Let us consider the following example that requires data transformation from SapOrder to BaanOrder schema. The objective of the Transformation application is to map common elements of these two structures.
<sap:SapOrder xmlns:sap="http://schemas.cordys.com/SapApp"> <sap:OrderId/> <sap:OrderDate/> <sap:OrderedBy/> <sap:CustomerId/> <sap:CustomerAddress/> <sap:ShipmentDate/> </sap:SapOrder>
<baan:BaanOrder xmlns:baan="http://schemas.cordys.com/BaanApp"> <baan:OrderIdentifier/> <baan:CustomerIdentifier/> <baan:OrderDate/> <baan:ShipmentDate/> <baan:OrderDetails/> <baan:ShipmentAddress/> </baan:BaanOrder>
Data transformation can be created using the schema fragments that are generated by either of the following documents:
- Object Templates
- WS-AppServer Custom Class
However, in BOP 4.1, since you cannot create a new Object Template, you can use a WS-AppServer Custom Class to achieve the result. This section contains the procedure on using the WS-AppServer custom class instead of an Object Template.
Using WS-AppServer Custom Class in the Transformation application
Pre-requisites
It is assumed that:
- user has "Developer" and "Administrator" role
- user has already created a workspace and a project or has an existing CWS project.
- Create a new WS-AppServer Package, for instance, SapApp which has the namespace='http://schemas.cordys.com/SapApp'.
Note: Ensure that the namespace of this package is same as the namespace of the object template - On the WS-AppServer Package toolbar, click . The Create Class from Object Layout dialog box appears.
- Use the following object layout for the SapOrder schema.
Note: You can use the Layout Tree tab to build the layout. If you are familiar with the WS-AppServer custom class layouts, you can directly use the layout. In this instance, all the elements are of type 'string'. If required, you can use a relevant type.
SapOrder Pure Custom Class Layout<SapOrder> <OrderId unique="true">string</OrderId> <OrderDate>string</OrderDate> <OrderedBy>string</OrderedBy> <CustomerId>string</CustomerId> <CustomerAddress>string</CustomerAddress> <ShipmentDate>string</ShipmentDate> </SapOrder>
- Click OK. A custom class with the relevant attributes and methods is generated.
- On the WS-AppServer Package toolbar, click on Generate WebServiceInterface. A Web service generation wizard is displayed.
- Select the custom class and follow instructions on the wizard. At the end, a Web service Interface along with the Schema for SapOrder is generated.
- Repeat the steps 1 to 5 for creating BaanOrder. Provide the following details in the relevant fields:
- WS-AppServer package name = BaanApp
- WS-AppServer package namespace='http://schemas.cordys.com/BaanApp'
- Custom class object layout
BaanOrder Pure Custom Class Layout
<BaanOrder> <OrderIdentifier unique="true">string</OrderIdentifier> <CustomerIdentifier>string</CustomerIdentifier> <OrderDate>string</OrderDate> <ShipmentDate>string</ShipmentDate> <OrderDetails>string</OrderDetails> <ShipmentAddress>string</ShipmentAddress> </BaanOrder>
- The schema for SapOrder and BaanOrder custom classes is generated along with the corresponding schema fragments.
- Create a new Data Transformation model , for instance, Sap_To_Baan_Transformation.
- Select SapOrder schema fragment as the Source and BaanOrder schema fragment as the target in the transformation modeler.
- Define the mappings.
- Generate a Web service on Sap_To_Baan_Transformation with SapOrder schema fragment as the input and use it in your application. For more information on generating a Web service on data transformation models, refer to Generating a Web service on Data Transformation Model
Guidelines to remodel Object Templates in the existing applications to WS-AppServer Custom Class
In order to have no break in the applications that used object templates, it is recommended to remodel the object templates to WS-AppServer Custom Classes. This section provides the guidelines to be followed while remodeling the object template into a WS-AppServer Custom Class.
- Create a WS-AppServer Custom Class that is same as the structure of the Object Template.
- If an Object Template had any special attributes, ensure that those attributes are qualified as unique attributes while modeling a custom class from object layout.
- If an Object Template is marked as 'Persistent', based on the object template structure, you can do any of the following:
- If Object Template is a simple structure, that is, a structure that does not have any nested elements , you can create the database table representing this structure (ORM) and generate WS-AppServer class(es) from the database. In this case, you need not write any additional logic in the generated class to persist the instance in application database; it is taken care by WS-AppServer framework itself.
- Use a 'Pure Custom' class. You can use this regardless of simple or nested structure. However, if you use this option, you must write additional business logic to persist the instance data in the application database.
- If the application is using Web services generated on object template, while generating Web services for custom class, you must ensure that name of the Web service and the names of the parameters match; that is, the custom class method and parameter names must match the parameter names of Web service generated on an object template.
- Since the Web service(s) generated on custom class are interpreted by the WS-AppServer framework, you have to delink the namespace from CoBOC Service Group and attach the Web services generated on custom class to WS-AppServer Service Group.
- If an object template had rules, decision table, or data transformations associated to it, then you have to update or remodel the respective rules, decision table or data transformation instances to use the schema fragments generated for WS-AppServer custom class and re-publish it.